/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package sellcar;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.swing.JOptionPane;

/**
 *
 * @author Fabio Valenzuela
 */
public class ComboboxDAO {
        public ResultSet dados_marca() throws SQLException {
        Connection conn = new ConnectionFactory().getConnection();
        ResultSet rsmarca = null;
        PreparedStatement ps = null;
        try {
            String sql = "SELECT * FROM tb_marca";
            ps = conn.prepareStatement(sql);
            rsmarca = ps.executeQuery();
        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, "Ocorreu um erro no processo " + e);
        } finally {
            return rsmarca;
        }
    }
        public ResultSet dados_modelo() throws SQLException {
        Connection conn = new ConnectionFactory().getConnection();
        ResultSet rsmodelo = null;
        PreparedStatement ps = null;
        try {
            String sql = "SELECT * FROM tb_modelo";
            ps = conn.prepareStatement(sql);
            rsmodelo = ps.executeQuery();
        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, "Ocorreu um erro no processo " + e);
        } finally {
            return rsmodelo;
        }
    }
        public ResultSet dados_cambio() throws SQLException {
        Connection conn = new ConnectionFactory().getConnection();
        ResultSet rscambio = null;
        PreparedStatement ps = null;
        try {
            String sql = "SELECT * FROM tb_cambio";
            ps = conn.prepareStatement(sql);
            rscambio = ps.executeQuery();
        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, "Ocorreu um erro no processo " + e);
        } finally {
            return rscambio;
        }
    }
        public ResultSet dados_combustivel() throws SQLException {
        Connection conn = new ConnectionFactory().getConnection();
        ResultSet rscombustivel = null;
        PreparedStatement ps = null;
        try {
            String sql = "SELECT * FROM tb_combustivel";
            ps = conn.prepareStatement(sql);
            rscombustivel = ps.executeQuery();
        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, "Ocorreu um erro no processo " + e);
        } finally {
            return rscombustivel;
        }
    }
        public ResultSet dados_porta() throws SQLException {
        Connection conn = new ConnectionFactory().getConnection();
        ResultSet rsporta = null;
        PreparedStatement ps = null;
        try {
            String sql = "SELECT * FROM tb_porta";
            ps = conn.prepareStatement(sql);
            rsporta = ps.executeQuery();
        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, "Ocorreu um erro no processo " + e);
        } finally {
            return rsporta;
        }
    }        
}